import { ss } from '@/utils/storage'
// ts文件引入ts文件时不需要加后缀，加后缀会报错
import type { IPdfMeta } from '@/views/pdf/DataModel'
const LOCAL_NAME = 'knowledgeHubStore'

export interface KnowledgeHubState {
  pdfSrc: string
  pdfMeta: IPdfMeta | null
  pdfid: number | bigint
}

// 获取后端存储的pinia状态
export function getLocalKnowledgeHubState(): KnowledgeHubState {
  // const knowledgeHubStore: KnowledgeHubState | undefined = ss.get(LOCAL_NAME)
  return { pdfSrc: '', pdfMeta: null, pdfid: 0 }
}

// 设置后端的pinia状态（这样即使刷新也不会被删除）
export function setLocalKnowledgeHubState(knowledgeHubStore: KnowledgeHubState): void {
  ss.set(LOCAL_NAME, knowledgeHubStore)
}
